package collection.homework.Demo2;


import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        Student s1 = new Student(1,"张无忌","河北");
        Student s2 = new Student(2,"张三丰","河南");
        Student s3 = new Student(3,"赵敏","蒙古");
        Student s4 = new Student(4,"周芷若","四川");
        ArrayList<Student> students = new ArrayList<Student>();
        students.add(s1);
        students.add(s2);
        students.add(s3);
        students.add(s4);
        for (Student student : students) {
            System.out.println(student);
        }
        repeatAddress(students);
        System.out.println("已修改:");
        for (Student student : students) {
            System.out.println(student);
        }
    }
    private static void repeatAddress(ArrayList<Student> students) {
        for (Student s : students) {
            if (s.getName().equals("张三丰")){
                s.setAddress("山东");
            }
        }
    }
}
